<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let data = {
            name: '刘亦菲',
            address: '中国',
            a: {
                b: 1
            }
        }

        const obs = new Observer(data)
        let vm = {}
        vm._data = data = obs
        function Observer(obj) {
            const keys = Object.keys(obj)
            keys.forEach((k) => {
                Object.defineProperty(this, k, {
                    get() {
                        return obj[k]
                    },
                    set(val) {
                        obj[k] = val
                    }
                })
            })
        }




    </script>
</body>

</html>